package com.walter.epay.util;

import cn.hutool.json.JSONUtil;
import com.walter.epay.param.response.EpayResponse;

public class JsonUtil {
    public static <T> EpayResponse<T> toEpayResponse(String jsonString, Class<T> type) {
        EpayResponse<T> epayResponse = JSONUtil.toBean(jsonString, EpayResponse.class);
        Object data = epayResponse.getData();
        if (epayResponse.isSuccess() && data != null) {
            T bean = JSONUtil.toBean(data.toString(), type);
            epayResponse.setData(bean);
        }
        return epayResponse;
    }
}
